package com.zjj.controller;

import com.zjj.entity.User;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;

@RestController
public class UserController {
    //普通参数
    @GetMapping("getname")
    public String name(String name){
        System.out.println("名字是"+name);
        return "接收普通参数";
    }

    //pojo参数
    @GetMapping("getPojoUser")
    public String getPojoUser (User user){
        System.out.println("接收pojo参数"+user);
        return "接收pojo参数";
    }

    //pojo嵌套参数
    @GetMapping("getPojoUsers")
    public String getPojoUsers(User user){
        System.out.println("接收pojo参数"+user);
        System.out.println("接收pojo镶嵌参数"+user.getRole());
        return "接收pojo镶嵌参数";
    }
    //数组
    @GetMapping("arrays")
    public String arraysParams(String[] hobbys){
        System.out.println("接收数组"+ Arrays.toString(hobbys));
        return "接收数组";
    }
    //集合
    @GetMapping("ListParams")
    public String ListParams(@RequestParam List<String> hobbyes){
        System.out.println("接收集合"+hobbyes);
        return "接收集合";
    }
    //接收JSON数组
    @PostMapping("postJson")
    public String postJson(@RequestBody List<User> users){
        System.out.println("json数据传递"+ users);
        return "json数据传递";
    }

}
